<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>User Management</title>
    <!--备注:引入外部css文件-->
    <link rel="stylesheet" href="homehandle.css">
</head>
<body>
    <!-- 左侧菜单栏 -->
    <div class="sidebar">
        <h2 onclick="toggleMenu()">主菜单 <span id="arrow">▼</span></h2>
        <div id="submenu" class="submenu">
            <div class="menu-item" onclick="showContent('createUser')">创建用户</div>
            <div class="menu-item" onclick="showContent('editUser')">编辑用户</div>
            <div class="menu-item" onclick="showContent('createRoom')">创建房间</div>
            <div class="menu-item" onclick="showContent('editRoom')">编辑房间</div>
        </div>
    </div>

    <!-- 右侧内容显示区域 -->
    <div class="content">
        <div id="createUser" class="content-section" style="display: none;">
            <h2>创建用户</h2>
            <form id="createUserForm">
                <div class="form-group">
                    <label for="username">用户名：</label>
                    <input type="text" id="username" name="username" maxlength="40" required style="width:300px;">
                </div>
                <div class="form-group">
                    <label for="password">密码：</label>
                    <input type="password" id="password" name="password" maxlength="40" required style="width:300px;">
                </div>
                <div class="form-group">
                    <label for="email">邮箱：</label>
                    <input type="text" id="email" name="email" maxlength="40" required style="width:300px;">
                </div>

                <button type="button" class="submit-btn" onclick="createUser()">确定创建</button>
                <button type="button" class="submit-btn" onclick="window.location.href='/login'">返回登录</button>
            </form>
        </div>

        <div id="editUser" class="content-section" style="display: none;">
            <h2>编辑用户</h2>
            <table id="userTable" border="1">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>用户名</th>
                        <th>房间ID</th>
                        <th>邮箱</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>

        <div id="createRoom" class="content-section" style="display: none;">
            <h2>创建房间</h2>
            <form id="createRoomForm">
                <div class="form-group">
                    <label for="roomname">房间名:</label>
                    <input type="text" id="roomname" name="roomname" maxlength="20" required style="width:300px;">
                </div>
                <div class="form-group">
                    <label for="roomcreateid">创建者ID:</label>
                    <input type="number" id="roomcreateid" name="roomcreateid" required style="width:300px;height:30px;">
                </div>
                <div class="form-group">
                    <label for="roomcapacity">房间容量:</label>
                    <input type="number" id="roomcapacity" name="roomcapacity" required style="width:300px;height:30px;">
                </div>
                <div class="form-group">
                    <label for="roomdesc">房间描述:</label>
                    <input type="text" id="roomdesc" name="roomdesc" maxlength="40" required style="width:300px;">
                </div>
                <button type="button" class="submit-btn" onclick="createRoom()">确定创建</button>
            </form>
        </div>

        <div id="editRoom" class="content-section" style="display: none;">
            <h2>编辑房间</h2>
            <table id="roomTable" border="1">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>房间名</th>
                        <th>创建者</th>
                        <th>成员上限</th>
                        <th>房间说明</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
    </div>
    <script src="homehandle.js"></script>
</body>
</html>